<template>
  <view class="container">
    <view class="header">
      <text class="title">订单记录</text>
    </view>

    <!-- 时间线展示订单状态 -->
    <view class="timeline">
      <view class="timeline-item" v-for="(item, index) in orderHistory" :key="index">
        <view class="status-container">
          <view class="circle" :class="{'active': item.active}"></view>
          <text class="status">{{ item.status }}</text>
        </view>
        <text class="description">{{ item.description }}</text>
        <text class="time">{{ item.time }}</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 订单的状态记录
      orderHistory: [
        {
          status: '订单已生成',
          description: '请您耐心等待，我们尽快催促师傅接单',
          time: '2023-12-25 08:26',
          active: true // 当前状态已完成，标记为 active
        },
        {
          status: '等待接单中…',
          description: '请您耐心等待，我们尽快催促师傅接单',
          time: '',
          active: true
        },
        {
          status: '王大壮师傅已接单',
          description: '师傅即将上门服务，请您耐心等待',
          time: '2023-12-25 08:26',
          active: true
        },
        {
          status: '上传图片(服务前)',
          description: '师傅已将服务前拍照图片上传至平台',
          time: '2023-12-25 08:26',
          active: true
        },
        {
          status: '上传图片(服务后)',
          description: '师傅已将服务后拍照图片上传至平台',
          time: '2023-12-25 08:26',
          active: false
        },
        {
          status: '待缴费',
          description: '师傅已将服务费用提交至平台，请您及时验收缴费',
          time: '2023-12-25 08:26',
          active: false
        },
        {
          status: '已缴费',
          description: '您已缴费成功，请您对本次服务进行评价',
          time: '2023-12-25 08:26',
          active: false
        },
        {
          status: '已评价',
          description: '感谢您对本次服务进行评价，今后系统将为您提供更优质的服务',
          time: '2023-12-25 08:26',
          active: false
        }
      ]
    };
  }
}
</script>

<style scoped>
.container {
  padding: 20px;
}

.header {
  padding-bottom: 10px;
}

.title {
  font-size: 20px;
  font-weight: bold;
}

.timeline {
  margin-top: 20px;
}

.timeline-item {
  display: flex;
  flex-direction: column;
  padding: 10px 0;
  padding-left: 30px;
  border-left: 2px solid #ddd;
  position: relative;
}

.status-container {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}

.circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #ddd;
  margin-right: 10px;
  position: absolute;
  left: 0;
  top: 5px;
}

.circle.active {
  background-color: #007aff; /* 当前状态高亮 */
}

.status {
  font-size: 16px;
  font-weight: bold;
}

.description {
  font-size: 14px;
  color: #888;
}

.time {
  font-size: 12px;
  color: #aaa;
  margin-top: 4px;
}

.timeline-item:not(:last-child) {
  margin-bottom: 15px;
}

</style>
